import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SRobIslandLog } from "../../../../../Message/Game/SRobIslandLog";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Cache } from "../../../cache/Cache";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { DateParser } from "../../../../common/tools/DateParser";
import { PetIslandUtil } from "../PetIslandUtil";
import { ERobIslandLogType } from "../../../../../Message/Game/ERobIslandLogType";
import { Language } from "../../../../../extend/language/Language";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class PetIslandRecordInfoItemRenderer
    
    export  class PetIslandRecordInfoItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */onLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (this._vo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandMapShowByPosition, this._vo.pos));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            super.data = arg1;
            if (typeof arg1 === "srobislandlog") 
            {
                this._vo = arg1 as SRobIslandLog;
                loc1 = HTMLUtil.addColor(Cache.instance.petIsland.powerBaseInfo.guildName, GlobalStyle.color6);
                if (this._vo.guildId.id > 0) 
                {
                    loc2 = HTMLUtil.addColor(" [" + EntityUtil.getProxyName(this._vo.guildId) + "]" + this._vo.guildName, GlobalStyle.color6);
                }
                else 
                {
                    loc2 = HTMLUtil.addColor(this._vo.guildName, GlobalStyle.color6);
                }
                loc3 = DateParser.parse(this._vo.logDt, "[MM-dd hh: mm: ss]");
                loc4 = PetIslandUtil.getPosName(this._vo.pos);
                this._record.defaultTextFormat = GlobalStyle.setTextFormatLeading(GlobalStyle._textFormat1, 5);
                var loc6=this._vo.logType;
                switch (loc6) 
                {
                    case ERobIslandLogType._ERobIslandLogTypeRob:
                    {
                        this._record.htmlText = Language.getStringByParam(28191, loc3, loc1, loc2 + loc4, this._vo.grassCount);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeLost:
                    {
                        this._record.htmlText = Language.getStringByParam(28192, loc3, loc1 + loc4, loc2, this._vo.grassCount, this._vo.grassLost);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeRecover:
                    {
                        this._record.htmlText = Language.getStringByParam(28193, loc3, loc1, loc4, this._vo.grassCount);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeDrop:
                    {
                        loc5 = GameDefConfig.instance.getPetIslandGuildPosName(this._vo.playerPos) + this._vo.playerName;
                        this._record.htmlText = Language.getStringByParam(28194, loc3, loc1 + loc5, loc4, this._vo.grassCount);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeFinish:
                    {
                        this._record.htmlText = Language.getStringByParam(28195, loc3, loc1, loc4, this._vo.grassCount);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeRobFail:
                    {
                        this._record.htmlText = Language.getStringByParam(28215, loc3, loc1, loc2 + loc4);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeRobDefense:
                    {
                        this._record.htmlText = Language.getStringByParam(28216, loc3, loc1, loc2);
                        break;
                    }
                    case ERobIslandLogType._ERobIslandLogTypeRefresh:
                    {
                        this._record.htmlText = Language.getStringByParam(28236, loc3, loc1 + loc4, this._vo.grassCount);
                        break;
                    }
                }
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._record = ObjCreate.createGTextField("", 10, 8, 530, 40, this, GlobalStyle.setTextFormatLeading(GlobalStyle._textFormat1, 5));
            this._record.wordWrap = true;
            this._record.multiline = true;
            this._record.addEventListener(flash.events.TextEvent.LINK, this.onLinkHandler);
            ObjCreate.createBg(3, 42, 550, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal */ /* var */_record: GTextFiled;

        /* internal */ /* var */_vo: SRobIslandLog;
    }
